package quoridorGame;


import java.util.Scanner;

/*
 * 
 * optional Main(Client)
 * A program written in Java does not necessarily need to have a main class.
 * A main/client class is considered as a client object which has a reference to the Object structure
 * in our case which is a Game
 *
 * 
 * http://www.oodesign.com/
 */
public class Main {
	public static final Scanner INPUT = new Scanner (System.in);
	private static void menu() {
		System.out.format("%15s\n", "Quoridor");
		System.out.println("---------------------");
		System.out.println("1: New Game");
		System.out.println("2: Load Game");
		System.out.println("3: Exit");
		System.out.print("Choose: ");
	}
	
	private static void invalidMessage()
	{
		System.out.println("Please choose an option on the menu");
	}
	
	// isInt checking 
	// idea sourced from http://www.daniweb.com/software-development/java/threads/130285
	public static boolean isInt(String inputStr) {
		try {
			Integer.parseInt(inputStr);
			return true;
		} catch (Exception exception) {
			return false;
		}
	}
	
	public static void main (String [] args)
	{
		//Board newBoard;
		int choice;
		String inputStr;
		menu();
		while(true) {
			// get in if the input is invalid
			INPUT.hasNext();
			inputStr = INPUT.next();
			// test if the input is an integer
			if (isInt(inputStr)) {
				choice = Integer.parseInt(inputStr);
				if (choice > 0 && choice <= 3) {
					break;
				}
			}
			invalidMessage();
			System.out.print("Choose: ");
		}
		
		switch (choice)
		{
			case 1:
				System.out.println("New game");
				//newBoard = new GameBoard();
				break;
			case 2:
				System.out.println("load game");
				//newBoard = new GameBoard();
				break;
			case 3:
				// exit the game
				System.out.println("Bye");
				break;
			default:
				// should never get into default
				throw new IllegalStateException ("something is wrong");
		}
	}
}
